home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11974 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: news.internex.net.au!usenet
  2. From: sultan@connexus.apana.org.au (Jon Hornstein)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Floating Point Error Traping by try and catch:-
  5. Date: Sun, 17 Mar 1996 14:29:33 GMT
  6. Organization: Yarra House Software Pty Ltd
  7. Message-ID: <4ih5bo$35d@preeda.internex.net.au>
  8. References: <4i836n$2u8@dfw-ixnews5.ix.netcom.com>
  9. NNTP-Posting-Host: dialin-10.internex.net.au
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Mission Impossible(?)
  13.  
  14. You assignment is to get the process associated function signal
  15. (interrupt) to throw a c++ exception. As far as I know signals are not
  16. related to c++ throws. I cannot comment on tool++ class library, but
  17. the library implementors must grapple with the same problem. My
  18. feelings are that the tools library must provide as much help to find
  19. your coding errors as possible. In the end other tools like lint
  20. processing and assertion points as well as must testing must be used
  21. to debug these sort of errors from a system.
  22.  
  23. rajash@ix.netcom.com(Rajash Gopalakrishnan ) wrote:
  24.  
  25. >Hi Experts!.
  26.  
  27. >We were using normal try and catch statements to trap
  28. >the exceptional errors occured during C++ class operation.
  29. >We are working on Soaris C++ 4.1 with Toolsh++ classes.
  30.  
  31. >Here is a sample program which causes floating point error.
  32. >If anybody have a clue, please tell me a method to trap
  33. >this error.
  34.  
  35. >BOOL Divide_By_Zero();
  36.  
  37. >main()
  38. >{
  39. >  try
  40. >  {
  41. >  Divide_By_Zero()
  42. >  }
  43. >  catch(long&)
  44. >  {
  45. >   cout << 'Got Error' << endl;
  46. >  }
  47. >}
  48.  
  49. >BOOL Divide_By_Zero()
  50. >{
  51. >  long i,j;
  52.  
  53. >  i= 4.0;
  54.  
  55. >  j = i/0;  // causing Floating Point Error
  56.  
  57. > return TRUE;
  58. >}
  59.  
  60. >Here what I found is that before catch, arithemetic experssion fault 
  61. >occurs and core is dumping. One method I found is to redirect the
  62. >signal
  63. >handler and do a catch but that's a round about method. Can anybody 
  64. >explain how we can handle this situation by try and catch alone. Is
  65. >there
  66. >any method to show where error occured and line#.
  67.  
  68. >Thanks 
  69. >Raj
  70.  
  71.  
  72.  
  73.